package com.example.druid.demo_druid.controller;

import com.example.druid.demo_druid.asynctask.TestTask;
import com.example.druid.demo_druid.service.ClassService;
import com.example.druid.demo_druid.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * @author devsun
 *         Created by on 2017/12/10.
 */
@Controller
public class TestController {

    @Autowired
    private StudentService studentService;
    @Autowired
    private ClassService classService;
    @Autowired
    private TestTask task;

    @RequestMapping(value = "/test")
    public void test(){
        List<Map<String, Object>> list = studentService.getList();
        List<Map<String, Object>> list2 = classService.getList();
    }

    @RequestMapping(value = "/test2")
    public void test2(){
        List<Map<String, Object>> list = classService.getList();
        System.out.println(list);
    }

    @RequestMapping(value = "/testAsync")
    public String testAsync() throws ExecutionException, InterruptedException {
        Future<String> stringFuture = task.test();
        System.out.println(stringFuture.get());
        System.out.println("------------------------------------");
        return "asd";
    }
}
